<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>资源搜索_资源共享平台</title>
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="stylesheet" href="/css/style.css"/>
</head>
<body>
<div th:include="common/header" class="header-wrapper"></div>
<div class="container-wrapper">
    <div class="left">
        <div class="data-list">
            <div class="data-list-title">
                <i class="layui-icon layui-icon-search"></i>
                <span class="head">条件检索</span>
            </div>
            <div class="data-search">
                <table>
                    <tr>
                        <td width="80px" style="padding-bottom: 28px;"><label class="data-title-sub">资源类别：</label></td>
                        <td>
                            <ul>
                                <li><a href="/"><span id="t_0">全部</span></a></li>
                                <li th:each="resType:${application.allResTypeList}">
                                    <a th:href="'/res/list?typeId='+${resType.id}" th:title="${resType.name}">
                                        <span th:id="'t_'+${resType.id}" th:text="${resType.name}"></span>
                                    </a>
                                </li>
                            </ul>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                    <tr style="border-top: dashed 1px #e6e6e6;height: 60px;">
                        <td width="80px"><label class="data-title-sub">关键词：</label></td>
                        <td>
                            <form action="/res/search" onsubmit="return submitData()">
                                <div class="layui-col-sm10">
                                    <input type="text" th:value="${q}" id="q" name="q" autocomplete="off" class="layui-input" style="height: 30px" />
                                </div>
                                <div class="layui-col-sm2" style="padding-left: 10px;">
                                    <input type="submit" class="layui-btn layui-btn-radius layui-btn-sm" value="&nbsp;&nbsp;搜&nbsp;&nbsp;索&nbsp;&nbsp;" />
                                </div>
                            </form>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="data-list">
            <div class="data-list-title">
                <i class="layui-icon layui-icon-template-1"></i>
                <span class="head">搜索 "<label style="color:red;" th:text="${q}"></label>" 的结果（总共搜索到 <label style="color:red;" th:text="${resultTotal}"></label> 条记录）</span>
            </div>
            <div class="data-result">
                <div th:if="${resultTotal==0}" align="center" style="padding-top: 20px">未查询到结果，请换个关键字试试看！</div>
                <ul th:if="${resultTotal!=0}">
                    <li th:each="res:${resList}" style="margin-bottom: 20px">
                        <span class="title"><a target="_blank" th:href="'/res/detail/'+${res.id}" th:title="${res.name}" th:utext="${res.name}"></a></span>
                        <span class="summary" th:utext="'摘要:'+${res.content}+'...'"></span>
                        <span class="link"><a target="_blank" th:href="'/res/detail/'+${res.id}" th:text="'http://localhost:8001/res/detail/'+${res.id}"></a>&nbsp;&nbsp;<label th:text="'发布日期：'+${res.publishDateStr}"></label></span>
                    </li>
                </ul>
            </div>
            <div align="center" style="" th:utext="${pageCode}"></div>
        </div>
    </div>
    <div class="right">
        <div class="data-list">
            <div class="data-list-title">
                <i class="layui-icon layui-icon-fire"></i>
                <span class="head">热门资源</span>
            </div>
            <div class="data-content">
                <ul>
                    <li th:each="hotRes:${hotResList}">
                        <a target="_blank" th:href="'/res/detail/'+${hotRes.id}" th:title="${hotRes.name}" th:text="${#strings.length(hotRes.name)>20} ? ${#strings.substring(hotRes.name,0,21)} : ${hotRes.name}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<div th:include="common/link" class="wrapper"></div>
<div th:include="common/footer" class="footer-wrapper"></div>
<script src="/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    let $, layer;
    layui.use(['layer', 'element'], function () {
        $ = layui.jquery,
            layer = layui.layer;

        // 分类选中效果
        let typeId = [[${session.typeId}]];
        $("#" + typeId).css("color", "red");
    });

    function submitData() {
        let q = $("#q").val();
        if (q == "") {
            layer.msg("请输入关键字！");
            $("#q").focus();
            return false;
        }
    }
    /*]]>*/
</script>
</body>
</html>